var timeout = 0;
var blocker = 0;

function ResetBlocker() {
	blocker = 0;
}

function UpdateResults(album, search) {
	var s;

	clearTimeout(timeout);
	timeout = setTimeout('ResetBlocker()', 300);

	if (blocker == 0) {
		blocker = 1;

		if (album != 0) {
			if (search == "0-9") {
				s = "+album_category:[0 to 9]";
			} else {
				s = "+album_category:"+search;
			}
		} else {
			s = search;
		}

		if (search.length > 0) {
			new Ajax.Updater('results', 'search.php?search='+s);
		}
	}
}

function KeyDown(e) { 
    var evt=(e)?e:(window.event)?window.event:null;
    if (evt) {
        var key = (evt.charCode)?evt.charCode:((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
        if (key == 13) {
            UpdateResults(0, $("txt_search").value);
        }
    }
}
document.onkeydown=KeyDown; 
if(!document.all) document.captureEvents(Event.KEYDOWN);
